package com.woniu.filter;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 李桢
 * @time 2021/03/31 17:09:57
 */
@Component
public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        if (request.getRequestURI().contains("verify")) {
            return true;
        }

        String token = request.getHeader("token");

        if (StringUtils.isEmpty(token)){
            return false;
        }

        return true;

    }
}
